package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import java.util.Locale;

import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.ColTypeContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.ColumnNameContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.ColumnNameTypeContext;
import org.zhadoop.streaming.util.StreamingDataType;

/**
 * 列名称语法解析
 * @author zwd
 *
 */
public class ColumnNameTypeVisitor extends AbsCQLParserBaseVisitor<ColumnNameTypeContext>{

	private ColumnNameTypeContext context = null;
	
	public ColumnNameTypeVisitor() {
		context = new ColumnNameTypeContext();
	}
	
	
	@Override
	protected ColumnNameTypeContext defaultResult() {
		return context;
	}
	
	
	@Override
	public ColumnNameTypeContext visitColumnName(ColumnNameContext ctx) {
		context.setColumnName(ctx.getText().toLowerCase(Locale.US));
		return context;
	}
	
	@Override
	public ColumnNameTypeContext visitColType(ColTypeContext ctx) {
		context.setColumnType(StreamingDataType.valueOf(ctx.getText().toUpperCase(Locale.US)));
		return context;
	}
	
}
